<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    #loading {
      width: 0px;
      height: 50px;
      background: #8e44ad;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 30px;
      color: #fff;
    }
  </style>
</head>
<body>
  <div id="loading">0%</div>
  <script src="./js/03-ajax.js"></script>
  <script>
    function query(name) {
      return ajax('http://localhost:3000/posts')
    }
    async function loadUser(users) {
      for(let i=0;i<users.length;i++) {
        let user = await query(users[i])
        let progress = (i+1)/users.length * 100
        console.log(progress)
        loading.style.width = progress + '%'
        loading.innerHTML = Math.round(progress) + '%'
      }
    }
    loadUser(['lisa', 'json', 'j'])

  </script>
</body>
</html>